package com.jcfy.project.module.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jcfy.framework.aspectj.lang.annotation.Log;
import com.jcfy.framework.aspectj.lang.enums.BusinessType;
import com.jcfy.project.module.domain.TWithdraw;
import com.jcfy.project.module.service.ITWithdrawService;
import com.jcfy.framework.web.controller.BaseController;
import com.jcfy.framework.web.domain.AjaxResult;
import com.jcfy.common.utils.poi.ExcelUtil;
import com.jcfy.framework.web.page.TableDataInfo;

/**
 * 提现Controller
 *
 * @author jiangfeng
 * @date 2020-08-05
 */
@RestController
@RequestMapping("/module/withdraw" )
public class TWithdrawController extends BaseController {
    @Autowired
    private ITWithdrawService tWithdrawService;

    /**
     * 查询提现列表
     */
    @PreAuthorize("@ss.hasPermi('module:withdraw:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(TWithdraw tWithdraw) {
        startPage();
        List<TWithdraw> list = tWithdrawService.selectTWithdrawList(tWithdraw);
        return getDataTable(list);
    }

    /**
     * 导出提现列表
     */
    @PreAuthorize("@ss.hasPermi('module:withdraw:export')" )
    @Log(title = "提现" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(TWithdraw tWithdraw) {
        List<TWithdraw> list = tWithdrawService.selectTWithdrawList(tWithdraw);
        ExcelUtil<TWithdraw> util = new ExcelUtil<TWithdraw>(TWithdraw. class);
        return util.exportExcel(list, "withdraw" );
    }

    /**
     * 获取提现详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:withdraw:query')" )
    @GetMapping(value = "/{withdrawId}" )
    public AjaxResult getInfo(@PathVariable("withdrawId" ) Long withdrawId) {
        return AjaxResult.success(tWithdrawService.selectTWithdrawById(withdrawId));
    }

    /**
     * 新增提现
     */
    @PreAuthorize("@ss.hasPermi('module:withdraw:add')" )
    @Log(title = "提现" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWithdraw tWithdraw) {
        return toAjax(tWithdrawService.insertTWithdraw(tWithdraw));
    }

    /**
     * 修改提现
     */
    @PreAuthorize("@ss.hasPermi('module:withdraw:edit')" )
    @Log(title = "提现" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWithdraw tWithdraw) {
        return toAjax(tWithdrawService.updateTWithdraw(tWithdraw));
    }

    /**
     * 删除提现
     */
    @PreAuthorize("@ss.hasPermi('module:withdraw:remove')" )
    @Log(title = "提现" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{withdrawIds}" )
    public AjaxResult remove(@PathVariable Long[] withdrawIds) {
        return toAjax(tWithdrawService.deleteTWithdrawByIds(withdrawIds));
    }
}
